package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizintegral"
	"time"
)

// HzIntegralWalletRecord holds the schema definition for the HzIntegralWalletRecord entity.
type HzIntegralWalletRecord struct {
	ent.Schema
}

// Fields of the HzIntegralWalletRecord.
func (HzIntegralWalletRecord) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("user_id").Comment("用户id"),
		field.Int64("integral_wallet_id").Comment("积分钱包id"),
		field.String("record_title").NotEmpty().Comment("记录标题"),
		field.String("record_number").NotEmpty().Comment("记录流水号"),
		field.Int64("record_amount").Default(0).Comment("记录积分數量（百分之一）"),
		field.Int64("record_status").Default(bizintegral.Income).Comment("记录状态，1、收入，2、支出"),
		field.Int64("record_type").Default(bizintegral.UnknownType).Comment("记录类型，0、默认类型，1、月结类型,2、数字货币兑换类型"),
		field.Int64("record_active_balance").Default(0).Comment("记录活期余额（百分之一）"),
		field.Int64("record_freeze_balance").Default(0).Comment("记录冻结余额（百分之一）"),
		field.Int64("created_at").Immutable().Optional().Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}

// Indexes of the Street.
func (HzIntegralWalletRecord) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("user_id"),
		index.Fields("integral_wallet_id"),
		index.Fields("record_number").Unique(),
		index.Fields("record_status"),
		index.Fields("record_type"),
	}
}

func (HzIntegralWalletRecord) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("积分钱包明细表"),
	}
}
